home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / gamesrc / fring11 / map_mak2.pas < prev    next >
Pascal/Delphi Source File  |  1992-12-17  |  5KB  |  170 lines

  1. {
  2. ***************************************************************************
  3. * MAP_MAKER2 - for (2/12/92)                                              *
  4. * FRINGDUS - The Game.                                                    *
  5. *                                                                         *
  6. *  By Jason Nunn (JsNO BAR----NUNN)                                       *
  7. *                                                                         *
  8. * Email: nunn@pandanus.cs.ntu.edu.au                                      *
  9. *                                                                         *
  10. * Description: allows you to change byte (sprite) values of the map file  *
  11. * matrix.                                                                 *
  12. *                                                                         *
  13. ***************************************************************************
  14. }
  15. program map_maker2;
  16.  
  17. uses crt;
  18.  
  19. const
  20.   nullchar               = #0;
  21.   enter                  = #13;
  22.   back_space             = #8;
  23.   bell                   = #7;
  24.   uparrow                = #0#72;
  25.   leftarrow              = #0#75;
  26.   rightarrow             = #0#77;
  27.   downarrow              = #0#80;
  28.   esc                    = #27;
  29.   space                  = ' ';
  30.   page_up                = #0'I';
  31.   page_down              = #0'Q';
  32.   home                   = #0'G';
  33.   eend                   = #0'O';
  34.  
  35.  
  36. type
  37.   map_attrib = record
  38.                  bloc : array[0..99,0..99] of byte;
  39.                end;
  40. map_file_attrib = file of map_attrib;
  41.  
  42. var
  43.   map_file  : map_file_attrib;
  44.   map       : map_attrib;
  45.   cy        : byte;
  46.   cx        : byte;
  47.   ccy       : integer;
  48.   ccx       : integer;
  49.   hcy       : integer;
  50.   hcx       : integer;
  51.   ch        : string[2];
  52.  
  53. {
  54. ***************************************************************************
  55. *                                                                         *
  56. * No Documentation - Code is obvious                                      *
  57. *                                                                         *
  58. ***************************************************************************
  59. }
  60. procedure enter_cell;
  61. var
  62.   inch      : string[20];
  63.   old_inch  : string[20];
  64.   errpos    : integer;
  65.  
  66. begin
  67.   old_inch := '';
  68.   ch := #0;
  69.   ccx := 0;
  70.   ccy := 0;
  71.   hcx := 0;
  72.   hcy := 0;
  73.   repeat
  74.     clrscr;
  75.     for cy := 0 to 20 do
  76.       for cx := 0 to 20 do
  77.       begin
  78.         gotoxy((1 + cx) * 3, cy + 1);
  79.         if (hcx = cx) and (hcy = cy) then
  80.         begin
  81.           textbackground(1);
  82.           textcolor(15);
  83.           write(map.bloc[cx + ccx, cy + ccy]);
  84.         end
  85.         else
  86.         begin
  87.           textbackground(0);
  88.           textcolor(7);
  89.           write(map.bloc[cx + ccx, cy + ccy]);
  90.         end;
  91.       end;
  92.     gotoxy(1,23);
  93.     textbackground(0);
  94.     textcolor(5);
  95.     write('Block: ', map.bloc[hcx + ccx, hcy + ccy]);
  96.  
  97.     ch := readkey;
  98.     if ch = #0 then ch := ch + readkey;
  99.  
  100.     if ch = enter then
  101.     begin
  102.       gotoxy(1,23);
  103.       textcolor(5);
  104.       write('Enter new Value: ');
  105.       readln(inch);
  106.       if inch = '' then inch := old_inch; {If you want to repeat a value,}
  107.                                           {Then just press return without}
  108.                                           {entering nothing}
  109.  
  110.       val(inch, map.bloc[hcx + ccx, hcy + ccy],errpos);
  111.       old_inch := inch;
  112.     end;
  113.  
  114.     if ch = uparrow then ccy := ccy - 1;
  115.     if ch = downarrow then ccy := ccy + 1;
  116.     if ch = leftarrow then ccx := ccx - 1;
  117.     if ch = rightarrow then ccx := ccx + 1;
  118.  
  119.     if ch = #0 then ch := ch + readkey;
  120.     if ch = 'i' then hcy := hcy - 1;
  121.     if ch = 'm' then hcy := hcy + 1;
  122.     if ch = 'j' then hcx := hcx - 1;
  123.     if ch = 'k' then hcx := hcx + 1;
  124.  
  125.     if ccy < 0 then ccy := 0;
  126.     if ccx < 0 then ccx := 0;
  127.     if ccy > (99 - 20) then ccy := (99 - 20);
  128.     if ccx > (99 - 20) then ccx := (99 - 20);
  129.  
  130.     if hcy < 0 then hcy := 0;
  131.     if hcx < 0 then hcx := 0;
  132.     if hcy > 20 then hcy := 20;
  133.     if hcx > 20 then hcx := 20;
  134.  
  135.   until ch = 's';
  136. end;
  137. {
  138. ***************************************************************************
  139. *                                                                         *
  140. * No Documentation - Code is obvious                                      *
  141. *                                                                         *
  142. ***************************************************************************
  143. }
  144. begin
  145.   if paramstr(1) = '-h' then
  146.   begin
  147.     writeln;   {logo.......hey ya!, hey ya!, hey ya!}
  148.     writeln('MAP_MAK2 - By Jason Nunn - (C) 1992 - This Game is Freeware');
  149.     writeln;
  150.     writeln('Instructions: Read Manual (readme.txt)');
  151.     writeln;
  152.   end
  153.   else
  154.   begin
  155.     assign(map_file, 'fring1.map');
  156.     {$I-}
  157.     reset(map_file);
  158.     {$I-}
  159.     if ioresult = 0 then
  160.     begin
  161.       read(map_file, map);
  162.     end;
  163.     enter_cell;
  164.     seek(map_file, 0);
  165.     rewrite(map_file);
  166.     write(map_file,map);
  167.     close(map_file);
  168.   end;
  169.   textcolor(7);
  170. end.